
package bolts.runtime

import scala.util.matching._
import scala.util.matching.Regex._

final class BoltRegex(val self: Regex) {

  def =~(s: String): Boolean = {
    self.findFirstMatchIn(s) match {
      case Some(m) => true
      case None => false
    }
  }

  def foreach(s: String)(f: MatchData => Unit): Unit = {
    val mi = self.findAllIn(s)
    for (_ <- mi) {
      f(mi)
    }
  }

  def search(s: String)(f: MatchData => Unit): Unit = {
    self.findFirstMatchIn(s) match {
      case Some(m) => f(m)
      case None => 
    }
  }
}
